package io;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

/**
 * @author yeweilin
 */
public class FileInputStreamTest {
    public static void main(String[] args) {
        InputStream fileInputStream = null;
        int count=0;
        try {
            fileInputStream = new FileInputStream("D:/1.txt");
            byte[] bytes=new byte[fileInputStream.available()];
            if ((count=fileInputStream.read(bytes))!=-1){
                fileInputStream.read(bytes,0,count);
            }
            String s = new String(bytes, StandardCharsets.UTF_8);
            System.out.println(s.trim());
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fileInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
